<?php 

if(Yii::app()->user->hasFlash('model')) {
	Yii::app()->user->flash('model', array('<div class="confirmation">', '</div>'));
	echo "</div>";
	return;
}

?>

<?php $this->widget('textedit.components.TextEditor', array('id'=>'updateuser')); ?>

<h2>Профил</h2>
<div class="yiiForm">
<?php
$this->breadcrumbs=array(
	Yii::t('yii','Profile')
);


$JFV=Yii::app()->jformvalidate;

$JFV->setOptions(array(
		'errorElement'=> 'div',
		'errorClass' => 'invalid',
        ));



echo $JFV->form();
?>

<?php echo Html::errorSummary($user); ?>

<div class="simple">
<?php echo Html::activeLabel($user,'email'); ?>
<?php echo $JFV->activeTextField($user,'email'); ?>
<p class="hint">Забележка: Ако смените email адреса си ще трябва да активирате акаунта си отново, чрез писмо изпратено на новия адрес.</p>
</div>

<div class="simple">
<?php echo Html::activeLabel($user,'about'); ?>
<?php echo $JFV->activeTextArea($user,'about'); ?>
<p class="hint">Това е описанието, което се изписва на публичният ви профил.<br />
Може да използвате <?php echo EHtml::link('Markdown syntax', 'http://daringfireball.net/projects/markdown/syntax', array('target'=>'_blank'))?>.
</p>
</div>

<div class="simple">
<?php echo Html::activeLabel($user,'website'); ?>
<?php echo $JFV->activeTextField($user,'website'); ?>
<p class="hint">Напишете го във вид http://example.com Това може да е персонален сайт, блог или нещо, което ви се струва интересно.</p>
</div>
<div class="simple">
<?php echo Html::activeLabel($user,'password'); ?>
<?php echo $JFV->activePasswordField($user,'password', array('value'=>'')); ?>
</div>
<div class="simple">
<?php echo Html::activeLabel($user,'password_repeat'); ?>
<?php echo $JFV->activePasswordField($user,'password_repeat', array('value'=>'')); ?>
</div>

<div class="simple">
<?php echo Html::activeLabel($user,'email_visible'); ?>
<?php echo $JFV->activeCheckBox($user,'email_visible'); ?>
</div>

<div class="simple">
<?php echo Html::activeLabel($user,'notify_comments'); ?>
<?php echo $JFV->activeCheckBox($user,'notify_comments'); ?>
</div>

<div class="simple">
<?php echo Html::activeLabel($user,'notify_messages'); ?>
<?php echo $JFV->activeCheckBox($user,'notify_messages'); ?>
</div>
<?php if (Yii::app()->user->hasAuth(Group::ADMIN)) { ?>
<div class="simple">
<?php echo Html::activeLabel($user, 'group_id'); ?>
<?php echo $JFV->activeDropDownList($user, 'group_id', EHtml::listData(Group::model()->getListed(), 'id', 'name')); ?>
</div>
<?php } ?>
<div class="action">
<?php echo Html::submitButton('Запази',array('class'=>'submit')); ?>
</div>

<?php echo $JFV->endForm(); ?>
</div><!-- yiiForm -->

<script type="text/javascript">
$("form").bind("submit", function() { return false; });

$('.submit').bind('click', function () {
  jQuery.ajax({
'type':'POST',
'dataType' : 'html',
'url': jQuery(this).parents("form").attr("action"),
'cache':false,
'data':jQuery(this).parents("form").serialize(),
'success':function(html){
jQuery("#content").html(html)}
});
  return false;
});

</script>
